﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace E2_WEBSITE.Code.Admin
{
    public class NewsController
    {
        NewsDataAccess m_NewsDataAccess = new NewsDataAccess();

        public DataTable GetNews()
        {
            try
            {
                return m_NewsDataAccess.GetNews();
            }
            catch (Exception)
            {
                throw;
            }
        }
        public NewsInfo GetNewsInfo(int id)
        {
            try
            {
                return m_NewsDataAccess.GetNewsInfo(id);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool InsertNews(int UserId, NewsInfo news)
        {
            try
            {
                int nid = m_NewsDataAccess.GetNewsFreeId();
                return m_NewsDataAccess.InsertNews(nid, UserId, news);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool UpdateNews(int nid, int UserId, NewsInfo news)
        {
            try
            {
                return m_NewsDataAccess.UpdateNews(nid, UserId, news);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool RemoveNews(int nid)
        {
            try
            {
                return m_NewsDataAccess.RemoveNews(nid);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
